<extend name="Base/common"/>
<block name="style">
    <link href="__CSS__/reset_index.css" rel="stylesheet" />
    <link href="__CSS__/index.css" rel="stylesheet">
    <style>
        .registerform li{
            padding-bottom:25px;
            zoom: 1;
            overflow: hidden;
        }
        .registerform .label{
            display:block;
            width:90px;
            margin: 0;
            font-size: 14px;
            color: #444444;
            padding-top: 4px;
            padding-right: 5px;
            float: left;
            text-align: right;
        }
        .registerform .inputxt{
            border: 1px solid #ccc;
            width:300px;
            float: left;
        }
        .action{
            margin-top: 30px;
            margin-bottom: 20px;
        }
        .yzmsubinput{
            -webkit-border-radius: 0;
            -moz-border-radius: 0;
            border-radius:0
        }
        .yzmsub{
            padding-left: 82px;
        }

        .bixu{
            margin-left: 5px;
            color: red;
            font-weight: bold;
        }
    </style>
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
</block>
<block name="body">
    <div class="warrper">
        <div class="header">
            <div class="w1000 clearFloat">
                <div class="xglogo floatLeft">
                    <a href="{:U('Index/index')}"><img src="__IMG__/index/xglogo.png" alt=""/></a>
                </div>

            </div>
        </div>


        <!--content-->
        <div class="content">
            <div class="w1000">
                <h3 class="xgh3">当前位置：<a href="">来访登记</a>&nbsp;>&nbsp;<a href="">学生信息添加</a></h3>
                <div class="clearFloat">
                    <div class="xgleft floatLeft">
                        <h3 class="xglefth3">来访登记</h3>
                        <div class="xgleftdiv">
                            <ul>
                                <li class="border-d-b-dddddd">
                                    <a href="{:U('Specific/index')}" class="xgleactive">信息添加</a>
                                </li>
                                <li>
                                    <a href="{:U('Specific/logout')}">退出登录</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                    <div class="xgright floatRight">
                        <h3 class="xgrighth3">学生信息添加</h3>
                        <div class="xgrightcont">
                            <form class="registerform">
                                <ul>
                                    <input type="hidden" name="id"  value="{$data.id}" />
                                    <li>
                                        <label class="label">姓名：</label>
                                        <input type="text" value="{$data.name}" name="name" class="inputxt" />
                                        <span class="bixu">*</span>
                                    </li>
                                    <li>
                                        <label class="label">身份证号：</label>
                                        <input type="text" value="{$data.ID_number}" name="ID_number" class="inputxt" />
                                        <span class="bixu">*</span>
                                    </li>
                                    <li>
                                        <label class="label">联系电话：</label>
                                        <input type="text" value="" name="mobile" class="inputxt" />
                                        <span class="bixu">*</span>
                                    </li>
                                    <li>
                                        <label class="label">家庭住址：</label>
                                        <input type="text" value="{$data.home_address}" name="home_address" class="inputxt" />
                                    </li>
                                    <li>
                                        <label class="label">毕业学校：</label>
                                        <input type="text" value="{$data.school}" name="school" class="inputxt" />
                                    </li>
                                    <li>
                                        <label class="label">专业：</label>
                                        <select name="major" class="sewidth">
                                           <volist name="major" id="vo">

                                               <option value="{$vo.id}" <if condition="$data['major'] eq $vo['id']">selected</if> >{$vo.title}</option>
                                           </volist>
                                        </select>
                                    </li>

                                </ul>
                                <div class="action">
                                    <div class="clearFloat">
                                        <div class="yzmsub floatLeft">
                                            <input type="button" value="确认" class="yzmsubinput"/>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>

                    </div>
                </div>
            </div>
        </div>
        <!--content end-->
    </div>
    <!--warrper end-->
</block>

<block name="script">
    <script type="text/javascript">
        $(function(){
            $(".yzmsubinput").click(function(){
                var $name=$("input[name=name]").val(),
                    $ID_number=$("input[name=ID_number]").val(),
                    $id=$("input[name=id]").val(),
                    $mobile=$("input[name=mobile]").val();

                if($name==''){
                    layer.msg("请填写学生名字");
                    return false;
                }

                if($ID_number==''){
                    layer.msg("请填写身份证号");
                    return false;
                }

                if($mobile==''){
                    layer.msg("请填写手机号");
                    return false;
                }


                if($ID_number!=''){
                    var reg = /^[1-9]{1}[0-9]{14}$|^[1-9]{1}[0-9]{16}([0-9]|[xX])$/;
                    if(reg.test($ID_number)){
                        if($id==''){
                            $.post('{:U("Specific/checkfield")}', {ID_number:$ID_number,type:2}, function(data){
                                if(data.status){
                                    layer.msg(data.info);
                                   return false;
                                }else{
                                    save_action();
                                }
                            });
                        }else{
                            save_action();
                        }
                    }else{
                        layer.msg("身份证号格式不正确");
                        return false;
                    }

                }


            })

        });

        function save_action(){
            $.post('{:U("Specific/saveSudentInfo")}', $("form").serialize(), function(data){
                if(data.status){
                    layer.msg(data.info)
                    setTimeout(function () {
                        if(data.url!=''){
                            location.href = data.url;
                        }else{
                            window.location.reload();
                        }
                    },1000);
                }else{
                    layer.msg(data.info);
                }
            });
        }
    </script>

</block>
